home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-20 / rs0422.zip / LEVEL1 / PK88.AS < prev    next >
Text File  |  1990-11-14  |  10KB  |  298 lines

  1. ;/*
  2. ; * Copyright 1988 by the Radio Amateur Telecommunications Society
  3. ; * and Thomas A. Moulton, W2VY
  4. ; *
  5. ; * This software may only be modified, copied, distributed or
  6. ; * executed for non-profit purposes by individuals operating
  7. ; * systems in the Amateur Radio Service.  Credit to the
  8. ; * author(s) and to the Radio Amateur Telecommunications Society
  9. ; * must be made in modules where RATS provided software is used,
  10. ; * and in any announcements and documentation.  
  11. ; *
  12. ; * As a non-profit, research and development organization,  the
  13. ; * Radio Amateur Telecommunications Society distributes software
  14. ; * in both executable and source forms.  This policy is in place
  15. ; * to encourage the development and distribution of OSI-based,
  16. ; * networking tools.  In order to protect the interests of the
  17. ; * Society and the authors, we have placed some conditions
  18. ; * of use on the software.  Other groups are encouraged
  19. ; * to place the same or similar guidelines on
  20. ; * software they produce.
  21. ; *
  22. ; * The Radio Amateur Telecommunications Society reserves the right
  23. ; * to specify and alter the terms under which software provided by
  24. ; * the Society may be used.  This policy is consistent with the 
  25. ; * objective of uniform and consistent "Open Systems Interconnections."
  26. ; * 
  27. ; * All acceptable Amateur Radio related uses of this software
  28. ; * will be outlined in the "ROSE Implementer's Guide".  Individuals
  29. ; * or organizations wishing to add to, or modify the provisions of
  30. ; * the guide to accommodate local or evolutionary requirements
  31. ; * should document the proposed change(s) and forward them to the
  32. ; * Society.  If accepted, written notification will be provided by
  33. ; * the Society to the submitting organization or individual(s).
  34. ; * The Society will then issue a "ROSE Implementer's Guide Change
  35. ; * Notice".  Periodically, the Society will re-issue the "ROSE 
  36. ; * Implementer's Guide" and incorporate the text of the change 
  37. ; * notices.  This procedure has been put in to place to ensure
  38. ; * compatibility between systems and to ensure their "Openness"
  39. ; * and interoperability.
  40. ; *
  41. ; * No part of this software may be used in other packages 
  42. ; * without prior authorization from the author or the Society.  
  43. ; * Software incorporating this module, all or in part, must be 
  44. ; * provided to the Society prior to distribution or use by
  45. ; * anyone not directly involved in testing of the revised  
  46. ; * environment.  Current releases of the combined software must
  47. ; * be provided to the Society in both source and executable
  48. ; * forms.  Adequate documention to produce an executable module 
  49. ; * from the provided source must also be included.
  50. ; *
  51. ; * Non-Amateur Radio non-profit uses may be authorized on a case
  52. ; * by case basis.  Inquiries for such use may be made in writing
  53. ; * to the Society. Non-commercial uses consistent with the
  54. ; * general principles of Open Systems Interconnection Reference
  55. ; * Model will be generally considered with favor.
  56. ; *
  57. ; * Commercial licensing of the software is also available based
  58. ; * on normal commercial terms.  Licensing inquiries should be
  59. ; * directed to the Society.  Commercial licensing of the standard
  60. ; * software will be done in situations which materially benefit
  61. ; * the Amateur Radio Packet Network.  Additional licensing is
  62. ; * reserved by the individual authors.
  63. ; * 
  64. ; * The Radio Amateur Telecommunications Society provides this software
  65. ; * on an "as is" basis.  The Society assumes no liability for
  66. ; * loss incurred through the use of this software.  Amateur Radio
  67. ; * use of this software implies non-commercial and voluntary 
  68. ; * development, deployment and use of this software in a "Amateur",
  69. ; * non-commercial service.  Commercial users are encouraged to
  70. ; * inspect their copies of the source code.  Source code modification
  71. ; * licenses are available if a combined Object and Source Code
  72. ; * license was not originally established.
  73. ; * 
  74. ; * The Society may be contacted by writing or calling at:
  75. ; * 
  76. ; * The Radio Amateur Telecommunications Society 
  77. ; * 206 North Vivyen Street.
  78. ; * Bergenfield, New Jersey 07621
  79. ; *
  80. ; * Telephone: 201-387-8896
  81. ; *
  82. ; */
  83. ;
  84. ; System Init for ROM
  85. ;
  86.     psect    text,pure
  87.  
  88. *INCLUDE RCONFIG.LIB
  89. *INCLUDE STRUCT.LIB
  90.  
  91. MSYNC    EQU    10H
  92. CTS    EQU    5        ;SIO RR0 CTS Bit (Mask 20h)
  93. MDCD    EQU    08H
  94. MRTS    EQU    02H
  95.  
  96. POWER_FAIL EQU    0150H
  97.  
  98.     GLOBAL    CLKBIT, TICKCNT, HDWbss, HDLI
  99.  
  100.     psect    text
  101. start:    di            ;Insure NO int's!!
  102.     jp    POWER_FAIL    ;Power Failure, check memory, etc
  103.     jp    INIT_HDW    ;Set up SDS's based on the machine type
  104.     jp    INIT_LED    ;Init Led's
  105.     jp    UPD_LED        ;Change Led's (toggle)
  106.     jp    halted        ;We are halted...
  107.  
  108.     global    amul, brelop, wrelop, csv, cret
  109.  
  110. RST2:    jp    (hl)        ;for optimizer    **********'0010'**************
  111.     defm    'AEA PK-'
  112. RST3:    jp    amul        ;for optimizer    **********'0018'**************
  113.     defm    '87/88'
  114. RST4:    jp    brelop        ;for optimizer    **********'0020'**************
  115.     defm    'VHF  '
  116. RST5:    jp    wrelop        ;for optimizer    **********'0028'**************
  117.     defm    'W2VY'
  118.     defb    0
  119. RST6:    jp    csv        ;for optimizer    **********'0030'**************
  120.     defm    'ROSE'
  121.     defb    0
  122. RST7:    ex    (sp),hl        ;for optimizer    **********'0038'**************
  123.     pop    hl
  124.     jp    cret
  125.  
  126. tickcnt: defb    12        ;Clock is at 600 hz
  127.     defw    TBAUD+1        ;Pointer to Terminal baud rate
  128.     defw    RBAUD+1        ;Pointer to Radio baud rate byte (SCCBI)
  129. ileds:    defb    09h        ;Initial LED Pattern
  130.     defw    SDSI0, SDSI1
  131.  
  132.     global    SDS0, SDS1
  133.  
  134. ;  Initialize the SCC data structures
  135.  
  136. INIT_HDW:
  137.     LD    HL,SDSI0    ;Copy from ROM
  138.     LD    DE,SDS0        ;To RAM
  139.     LD    BC,SDSILEN
  140.     LDIR
  141.  
  142.     LD    HL,SDSI1    ;Copy from ROM
  143.     LD    DE,SDS1        ;To RAM
  144.     LD    BC,SDSILEN
  145.     LDIR
  146.  
  147.     LD    A,09
  148.     LD    C,0F2H
  149.     OUT    (C),A        ;WR 9
  150.     LD    A,0C0H        ;Master Reset for SCC
  151.     OUT    (C),A
  152.  
  153.     LD    A,MSYNC        ;PK-87/88 Clock bit (SYNC)
  154.     LD    (CLKBIT),A    ;Save it
  155.     LD    A,(tickcnt)    ;Clock is at 600 hz
  156.     LD    (TICKCNT),A    ;Number of Interrupts/Tick to 10ms
  157.  
  158. ;    Radio Port PTT/DCD is always normal
  159.  
  160.     LD    HL,0FF02h    ;PTTMSK1=MRTS, PTTMSK2=FF
  161.     LD    (SDS0+PTTMSK1),HL
  162.     XOR    A
  163.     LD    B,A        ;DCD is Normal - No Toggle
  164.     LD    (SDS0+DCDTGL),A
  165.  
  166. ;    Is the async port on a NetRom back-to-back cable?
  167.  
  168.     LD    A,(SDS1+CPORT)    ;Async Port
  169.     LD    C,A        ;Port Address
  170.     IN    A,(C)        ;Get RR0 Status
  171.     BIT    CTS,A        ;CTS ON?
  172.     JR    NZ,1f        ;No, Don't Invert RTS and DCD
  173.     LD    HL,7D00h    ;PTTMSK1=00, PTTMSK2=~MRTS
  174.     LD    B,MDCD        ;Toggle DCD Bit
  175.     LD    A,(SDS1+WR5REG)
  176.     OR    MRTS        ;Set the Async PTT to the right idle State
  177.     LD    (SDS1+WR5REG),A
  178. 1:    LD    (SDS1+PTTMSK1),HL ;RTS Handling
  179.     LD    A,B          ;DCD Handling
  180.     LD    (SDS1+DCDTGL),A
  181.  
  182.     LD    IY,SDS0
  183.     CALL    HDLI
  184.     LD    IY,SDS1
  185.     CALL    HDLI
  186.  
  187.     RET
  188.  
  189. LATCH    EQU    0F4H    ;Address of LED Latch
  190.  
  191. INIT_LED:        ;Enter with (_COLD) in A and B
  192.     LD    C,LATCH
  193.     AND    0C0H    ;Make sure we only have 2 bits
  194.     SRL    A
  195.     SRL    A
  196.     LD    B,A
  197.     SRL    A
  198.     SRL    A
  199.     SRL    A
  200.     OR    B
  201.     OR    0C9H    ;Turn off Multi bit (Wait Light) and CON
  202.             ;And CONV, SEND
  203.     OUT    (C),A    ;Do it!
  204.     LD    (HDWbss+1),A    ;Last Write to LEDs
  205.     LD    A,(ileds)
  206.     OR    0C0H    ;Turn off Multi bit (Wait Light) and CON
  207.     LD    (HDWbss),A    ;This is where we save the LED status
  208.     RET
  209.  
  210. UPD_LED:
  211.     call    csv
  212.     IN    A,(0F8h)    ;Tickle Watchdog
  213.     LD    A,(HDWbss)    ;Get LEDS
  214.     AND    03FH        ;Drop High Bits
  215.     SRL    A        ;Shift LEDs
  216.     JP    NC,1f        ;If no CY, we are OK
  217.     OR    20H        ;Put lost bit back in...
  218. 1:    OR    0C0H        ;Wait Light OFF and CON LED OFF (To get -12 on Pin 8/RS-232)
  219.     LD    (HDWbss),A
  220.     OUT    (LATCH),A    ;Update LEDS
  221.     LD    (HDWbss+1),A    ;Last Write to LEDS
  222.     jp    cret
  223.  
  224. halted:    LD    A,(HDWbss+1)    ;Get Last Write to LEDS
  225.     XOR    80h
  226.     OUT    (LATCH),A
  227.     HALT
  228.     XOR    80h
  229.     OUT    (LATCH),A
  230.     RET
  231.  
  232.     GLOBAL    SDSI0, SDSI1
  233. SDSI0:    DEFB    0        ;Channel number
  234.     DEFB    0F3H        ;SCC data port
  235.     DEFB    0F2H        ;SCC control port
  236.     DEFW    DWAIT0
  237.     DEFW    TXDELAY0
  238.     DEFW    SCCAI        ;SYNC CONFIG
  239.     DEFB    SCCAIL        ;LEN
  240.     DEFB    0        ;Flags
  241.     DEFB    069h        ;WR5REG (DTR Now On, Port 2)
  242.  
  243. SDSI1:    DEFB    1        ;Channel number
  244.     DEFB    0F1H        ;SIO data port
  245.     DEFB    0F0H        ;SIO control port
  246.     DEFW    DWAIT1
  247.     DEFW    TXDELAY1
  248.     DEFW    SCCBI        ;8530 Async Config
  249.     DEFB    SCCBIL        ;LEN
  250.     DEFB    MASYNC+MTIMER+MAFT ;Line for timer
  251.     DEFB    068h        ;WR5REG DTR is Now ON, RTS Off
  252.     ENDC
  253.  
  254. ;  Fixed data
  255.  
  256. ;  SCC SYNC initialization block.
  257.  
  258. SCCAI:    DEFB    4,0A0H        ;X32, SDLC, Sync
  259.     DEFB    10,0A0H        ;Init CRC, NRZI
  260.     DEFB    7,7EH        ;Sync Definitition (No S!!t)
  261.     DEFB    2,0H        ;Interrupt Vector
  262.     DEFB    3,0DAH        ;8 bit Rx, Enter Hunt, RXCRC, Sync Load Inh.
  263.     DEFB    5,68H        ;8 Bit Tx, Tx Enable
  264. ; next 3 lines are for internal baud rate with external divider for TXC
  265.     DEFB    11,66H    ;RXC=DPLL O/P, TXC=RTxC, TRxC=O, TRxC Out=BRG Out
  266. RBAUD:    DEFB    12,62,13,0    ;Time Constant (1200 Baud) (PCLK/(2*32*baud))-2
  267. ;    300 baud = 254, 600 baud = 126, 1200 baud = 62, 9600 baud = 6
  268.     DEFB    14,82H        ;Set Source=BRG, BR Generator source
  269. ; next 2 lines are for external clocks
  270. ;    DEFB    11,68H        ;RXC = DPLL Out, TXC = TRxC, TRxC=IN,
  271. ;    DEFB    14,0A0H        ;DPLL Source = RTxC (x32 clock)
  272.         DEFB    5,069H        ;DTR Off(7910),8 bitTx,TxEnable,TX CRC Enable
  273.     DEFB    3,0DBH        ;Same as 3 above, RX Enable
  274.     DEFB    14,23H        ;Enter Search Mode, Enable BRG
  275.     DEFB    15,0D8H        ;Enable Interrupts on 
  276.     DEFB    10H,10H        ;Reset External Interupts, Twice
  277.     DEFB    1,13H        ;Interrupt on Receive and Xmit
  278. SCCAIL    EQU     $-SCCAI
  279.  
  280. ;  SCC ASYNC initialization block.
  281.  
  282. SCCBI:    DEFB    14h        ;WR 4 + Reset Ext Intr
  283.     DEFB    44H        ;16xClk + 1Stop + NoParity
  284. ; Internal baud rate generator
  285.     DEFB    11,56H        ;RXC = BRG, TXC = BRG, TRXC OUT, TRXC=BRG
  286. TBAUD:    DEFB    12,14,13,0    ;Time Constant (9600 Baud) (PCLK/(2*16*baud))-2
  287. ;    1200 baud = 126, 2400 = 62, 4800 = 30, 9600 = 14
  288.     DEFB    14,63H        ;Disable PLL, BRG Source, BRG Enable
  289. ; External Clocking
  290. ;    DEFB    11,00H        ;TXC, RXC - RTxC Pin
  291.     DEFB    3,0C1H        ;WR3, 8bit + RxEnable
  292.     DEFB    5,068H        ;WR5, DTR On + 8bit + TxEnable + RTS Off
  293.     DEFB    15,0D8H        ;Enable Interrupts on
  294.     DEFB    10H,10H        ;Reset External Ints
  295.     DEFB    1,13H         ;Enable rx, tx, ext ints
  296.     DEFB    9,9        ;Master Interrupt Enable, Vector Includes Stat
  297. SCCBIL    EQU    $-SCCBI
  298.